@file:JvmName("KLclass") //给此文件取别名

package com.hc.kotlin

import java.io.IOException
import kotlin.jvm.Throws

fun main() {
    val javaClass = JavaClass()
    println(javaClass.javaf1()) //Kotlin调用Java
    println(javaClass.jint)
    javaClass.exceptionf2() //Java IOException非必须处理
}

fun kotlinf1() = "Hello KotlinClass f1()"

@JvmOverloads //Java调用Kotlin时 可以任意传参(0-2个)
fun kotlinf2(left:String = "left hand",right:String = "right hand"){
    println("${left} , ${right}")
}

@Throws(IOException::class) //Java调用时 可捕获IOException 否则只能捕获到Throwable
fun kotlinf3(){
    throw IOException("kotlinf3")
}

var kvar = { v:String->
    println(v.toLowerCase().capitalize())
}
class KotlinClass{
    @JvmField //Java调用Kotlin时,直接对象.调用
    val kotlinvar = listOf("Hello","World")

    companion object{
        @JvmField
        var innervar = 10
        @JvmStatic
        fun innerf1(){
            println("Hello KotlinClass@object")
        }
    }
}